<div class="breadcrumbs" id="breadcrumbs">
    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="index">Bảng điều khiển</a>
        </li>

        <li>
            <a href="contract?do=list">Hợp đồng</a>
        </li>
        <li class="active">Quản lý hợp đồng</li>
    </ul>
</div>
<div class="page-content">
    <div class="page-header">
        <h1>
            Hợp đồng
            <small>
                <i class="icon-double-angle-right"></i>
                Quản lý hợp đồng
            </small>
        </h1>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <div class="row">
                <div class="col-xs-12">
                    <div class="table-header">
                        Danh sách hợp đồng
                    </div>
                    <div class="table-responsive">
                        <div id="sample-table-2_wrapper" class="dataTables_wrapper" role="grid">
                            <div id="contract">
                                <?php $this->widget('zii.widgets.grid.CGridView', array(
                                    'id' => 'contract-grid',
                                    'dataProvider' => $model->search(),
                                    'summaryText' => '',
                                    'itemsCssClass' => 'table table-striped table-bordered table-hover dataTable',
                                    'htmlOptions' => array('style' => 'padding:0;'),
                                    'afterAjaxUpdate' => 'reinstallDatePicker',
                                    'pagerCssClass' => 'dataTables_paginate paging_bootstrap',
                                    'filter' => $model,
                                    'columns' => array(
                                        array('name' => 'contract_id', 'htmlOptions' => array('style' => 'width:50px'), 'filter' => false),
                                        array(
                                            'header' => '<a href="#">Thao tác</a>',
                                            'class' => 'CButtonColumn',
                                            'htmlOptions' => array('style' => 'width:110px', 'class' => 'visible-md visible-lg hidden-sm hidden-xs action-buttons'),
                                            'template' => '{view}{copy}{update}{delete}',
                                            'buttons' => array(
                                                'view' => array(
                                                    'label' => '<i class="icon-zoom-in bigger-130"></i>',
                                                    'imageUrl' => false,
                                                    'options' => array(
                                                        'class' => 'blue contract_view fancybox.ajax',
                                                    )
                                                ),
                                                'copy' => array(
                                                    'label' => '<i class="icon-copy bigger-130"></i>',
                                                    'url' => 'Yii::app()->createUrl("contract/create",array("id"=>$data->contract_id))',
                                                    'imageUrl' => false,
                                                    'options' => array(
                                                        'class' => 'orange',
                                                    )
                                                ),
                                                'update' => array(
                                                    'label' => '<i class="icon-edit bigger-130"></i>',
                                                    'imageUrl' => false,
                                                    'options' => array(
                                                        'class' => 'green contract_edit fancybox.ajax',
                                                    )
                                                ),
                                                'delete' => array(
                                                    'label' => '<i class="icon-trash bigger-120"></i>',
                                                    'imageUrl' => false,
                                                    'options' => array(
                                                        'class' => 'red',
                                                    )
                                                ),
                                            )
                                        ),
                                        array('name' => 'date', 'htmlOptions' => array('style' => 'width:95px;text-align:center;'),
                                            'filter' => $this->widget('ext.NavaDatePicker.DatePicker', array(
                                                'model' => $model,
                                                'attribute' => 'date',
                                                'htmlOptions' => array(
                                                    'id' => 'datepicker_for_date',
                                                    'size' => '10',
                                                    'data-date-format' => "dd-mm-yyyy"
                                                ),
                                                'options' => array(
                                                    'language' => "vi",
                                                    'format' => 'dd-mm-yyyy',
                                                    'autoclose' => true,
                                                    'orientation' => "top left",
                                                )
                                            ), true),
                                        ),
                                        array('name' => 'contract', 'type' => 'raw', 'value' => 'CHtml::link($data->name,$data->viewUrl, array("class"=>"contract_view fancybox.ajax"))', 'htmlOptions' => array('style' => 'width:110px')),
                                        array('name' => 'name', 'type' => 'raw', 'value' => 'CHtml::link($data->name,$data->viewUrl, array("class"=>"contract_view fancybox.ajax"))', 'htmlOptions' => array('style' => 'width:220px')),
                                        array('name' => 'tax', 'htmlOptions' => array('style' => 'width:120px')),
                                        array('name' => 'address'),
                                    ),
                                ));
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(".contract_view").fancybox();
    //$(".contract_edit").fancybox();
    function reinstallDatePicker() {
        $('#datepicker_for_date').datepicker({
            'format': 'dd-mm-yyyy',
            'autoclose': true,
            'orientation': "top left",
            'language': "vi"
        });
    }

</script>